<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Link_model extends CI_Model {
    
    public $tb_link = 'link';
    
    function __construct() {
        parent::__construct();
        $this->load->library('session');
    }

    public function get_link_by($post_id = "", $category_id = "")
    {
        $dbprefix = $this->config->item('dbprefix');
        $WHERE = "";
        if($post_id != "")
            $WHERE .= " AND `post_id` = '$post_id' ";
        if($category_id != "")
            $WHERE .= " AND `category_id` = '$category_id' ";
        $sql = "SELECT * FROM ". $dbprefix.$this->tb_link ." WHERE 1=1 $WHERE";
        $data = $this->db->query($sql)->row_array();
        return $data;
    }


 
}
